Skip to content

Figure out why liboat_hook.so is ineffective#194

Merged
JingMatrix merged 1 commit intomasterfrom
dex2oat
Feb 18, 2025
Merged

Figure out why liboat_hook.so is ineffective#194
JingMatrix merged 1 commit intomasterfrom
dex2oat

Conversation

@JingMatrix
Copy link
Copy Markdown
Owner

Add more logs for the hooking process.

@JingMatrix JingMatrix linked an issue Feb 18, 2025 that may be closed by this pull request
1 task
@JingMatrix
Copy link
Copy Markdown
Owner Author

JingMatrix commented Feb 18, 2025

With the log commit ead3d99, we get

  1. logs of starting the Dex2Oat service:
[ 2025-02-18T19:48:01.262        0:  1375:  1375 W/LSPosedDex2Oat  ] Check mount failed for /apex/com.android.art/bin/dex2oat32
[ 2025-02-18T19:48:01.267        0:  1673:  1673 I/LSPosed         ] Enable dex2oat wrapper
[ 2025-02-18T19:48:01.292        0:  1375:  1375 D/LSPosedDex2Oat  ] Check mount succeeded
[ 2025-02-18T19:48:01.292        0:  1375:  1375 D/LSPosedDex2Oat  ] SELinux status changed
[ 2025-02-18T19:48:01.293        0:  1375:  1720 I/LSPosedDex2Oat  ] Dex2oat wrapper daemon start
[ 2025-02-18T19:48:01.293        0:  1375:  1375 E/SELinux         ] avc:  denied  { execute } for  scontext=u:r:untrusted_app:s0 tcontext=u:object_r:dex2oat_exec:s0 tclass=file permissive=0
[ 2025-02-18T19:48:01.293        0:  1375:  1375 E/SELinux         ] avc:  denied  { execute_no_trans } for  scontext=u:r:untrusted_app:s0 tcontext=u:object_r:dex2oat_exec:s0 tclass=file permissive=0
[ 2025-02-18T19:48:01.293        0:  1375:  1720 D/LSPosedDex2Oat  ] wrapper path: l1s6vh34jtjzkhcdhbd0pdmhpzusrjdw
[ 2025-02-18T19:48:01.293        0:  1375:  1720 D/LSPosedDex2Oat  ] Setting SELinux label for bin/liboat_hook32.so
[ 2025-02-18T19:48:01.293        0:  1375:  1543 D/LSPosedService  ] LSPSystemServerService::LSPSystemServerService onRegistration: serial org.lsposed.lspd.service.LSPSystemServerService@e1fe776
[ 2025-02-18T19:48:01.293        0:  1375:  1720 D/LSPosedDex2Oat  ] Setting SELinux label for bin/liboat_hook64.so
[ 2025-02-18T19:48:01.293        0:  1375:  1720 E/LSPosedDex2Oat  ] Starting Dex2oat wrapper daemon
[ 2025-02-18T19:48:01.309        0:  1375:  1375 I/LSPosedService  ] service package is not started, wait 1s.
  1. logs during re-optimizing an app
02-18 20:12:12.730 17654 17654 D LSPosedDex2Oat: dex2oat.c:94#int main(int, char **): dex2oat wrapper ppid=17646
02-18 20:12:12.731  1375  1720 D LSPosedDex2Oat: Sent fd of /apex/com.android.art/bin/dex2oat64
02-18 20:12:12.731  1375  1720 D LSPosedDex2Oat: Sent fd of /data/adb/modules/zygisk_lsposed/bin/liboat_hook64.so
02-18 20:12:12.731 17654 17654 D LSPosedDex2Oat: dex2oat.c:120#int main(int, char **): sock: l1s6vh34jtjzkhcdhbd0pdmhpzusrjdw 5
02-18 20:12:12.731 17654 17654 D LSPosedDex2Oat: dex2oat.c:140#int main(int, char **): Set env LD_PRELOAD=/proc/17654/fd/13
02-18 20:12:12.731 17654 17654 D LSPosedDex2Oat: dex2oat.c:145#int main(int, char **): stock_fd: 5, hooker_fd: 13
02-18 20:12:12.766 17654 17654 W dex2oat64: Obsolete flag --compact-dex-level ignored
02-18 20:12:12.769 17654 17654 W dex2oat64: Mismatch between dex2oat instruction set features to use (ISA: Arm64 Feature string: -a53,crc,lse,fp16,dotprod,-sve) and those from CPP defines (ISA: Arm64 Feature string: -a53,-crc,-lse,-fp16,-dotprod,-sve) for the command line:
02-18 20:12:12.769 17654 17654 W dex2oat64: /apex/com.android.art/bin/dex2oat64 --zip-fd=6 --zip-location=/data/app/~~LauTIHP9KsD1nd56th9dkA==/org.adaway-aM_A8tN9dFE1AXz2QuqPnA==/base.apk --oat-fd=7 --oat-location=/data/app/~~LauTIHP9KsD1nd56th9dkA==/org.adaway-aM_A8tN9dFE1AXz2QuqPnA==/oat/arm64/base.odex --output-vdex-fd=8 --swap-fd=9 --class-loader-context-fds=10:11 --class-loader-context=PCL[]{PCL[/system_ext/framework/androidx.window.extensions.jar]#PCL[/system_ext/framework/androidx.window.sidecar.jar]} --classpath-dir=/data/app/~~LauTIHP9KsD1nd56th9dkA==/org.adaway-aM_A8tN9dFE1AXz2QuqPnA== --input-vdex-fd=12 --instruction-set=arm64 --instruction-set-features=default --instruction-set-variant=cortex-a55 --compiler-filter=verify --compilation-reason=cmdline --compact-dex-level=none --max-image-block-size=524288 --resolve-startup-const-strings=true --generate-mini-debug-info --runtime-arg -Xtarget-sdk-version:33 --runtime-arg -Xhidden-api-policy:enabled --runtime-arg -Xms64m --runtime-arg -Xmx512m --comments=app-name:org.adaway,app-version-name:6.1.4,app-version-code:60104,art-version:360105020 --inline-max-code-units=0
02-18 20:12:12.769 17654 17654 I dex2oat64: /apex/com.android.art/bin/dex2oat64 --output-vdex-fd=8 --class-loader-context-fds=10:11 --class-loader-context=PCL[]{PCL[/system_ext/framework/androidx.window.extensions.jar]#PCL[/system_ext/framework/androidx.window.sidecar.jar]} --classpath-dir=/data/app/~~LauTIHP9KsD1nd56th9dkA==/org.adaway-aM_A8tN9dFE1AXz2QuqPnA== --input-vdex-fd=12 --compiler-filter=verify --compilation-reason=cmdline --compact-dex-level=none --max-image-block-size=524288 --resolve-startup-const-strings=true --generate-mini-debug-info --comments=app-name:org.adaway,app-version-name:6.1.4,app-version-code:60104,art-version:360105020 --inline-max-code-units=0
02-18 20:12:12.794 17654 17654 I dex2oat64: Using CollectorTypeCMC GC.
02-18 20:12:13.196 17654 17654 I dex2oat64: dex2oat took 432.890ms (229.675ms cpu) (threads: 8) arena alloc=0B (0B) java alloc=5175KB (5299264B) native alloc=1560KB (1598144B) free=1206KB (1235632B)

It is still unclear why liboat_hook.so becomes ineffective after we set the SELinux label xposed_file for it in Dex2OatService.java.

It turns out that, if we call `putenv` inside the if block, then it is no longer valid out of the block.
@JingMatrix JingMatrix marked this pull request as ready for review February 18, 2025 19:38
@JingMatrix JingMatrix merged commit f31fc71 into master Feb 18, 2025
1 check passed
@JingMatrix
Copy link
Copy Markdown
Owner Author

However, we still need to explain why the env LD_LIBRARY_PATH can be set inside an if block but not the env LD_PRELOAD.
@aviraxp, do you have any idea ?

JingMatrix added a commit that referenced this pull request Feb 23, 2025
User has reported `dex2oat` failure with SELinux log:

```
W dex2oat64: type=1400 audit(0.0:922): avc: denied { read } for path="/data/adb/modules/zygisk_lsposed/bin/liboat_hook64.so" dev="dm-58" ino=91204 scontext=u:r:dex2oat:s0 tcontext=u:object_r:adb_data_file:s0 tclass=file permissive=0
```

Hence, we now set the SELinux context of `liboat_hook.so` in Dex2OatService.

Moreover, by the pull-request #194, we have to move `putenv` out of the if block by testing.
Indeed, if we call `putenv` inside the if block, then it is no longer valid out of the block.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Commit 8f8f632 renders liboat_hook.so ineffective

1 participant